<template>
  <div class="right-content">
    <list-content title-content="云控平台" >
      <template v-slot:content>
        <div id="statusBox" style="height:360px">
          <control-hand :camera-num="cameraNum" :camera-type="cameraType" :presetList="presetList"></control-hand>
        </div>
      </template>
    </list-content>

    <list-content title-content="摄像头信息">
      <template v-slot:content>
        <!-- element-loading-background="rgba(0, 0, 0, 0.8)" -->
        <div id="sumBox" style="height:30vh;" v-loading="loading" class="imscrollo">
          <div v-if="!Object.keys(cameraInfo).length" style="line-height:200px;text-align:center">暂无数据</div>

          <ul class="camera-info" v-else>
            <li class="camera-info-list">
              <span class="info-title">设备名称</span>
              <span class="info-value">{{cameraInfo.camName}}</span>
            </li>
            <li class="camera-info-list">
              <span class="info-title">所属组织</span>
              <span class="info-value">{{cameraInfo.deptName}}</span>
            </li>
            <li class="camera-info-list">
              <span class="info-title">设备编号</span>
              <span class="info-value">{{cameraInfo.camId}}</span>
            </li>
            <li class="camera-info-list">
              <span class="info-title">在线状态</span>
              <span class="info-value" v-if="cameraInfo.status == '0'">正常</span>
              <span class="info-value" v-if="cameraInfo.status == '1'">停用</span>
              <span class="info-value" v-if="cameraInfo.status == '2'">网络正常无图像</span>
            </li>
            <li class="camera-info-list">
              <span class="info-title">设备方向</span>
              <span class="info-value">{{cameraInfo.camOverlap}}</span>
            </li>
            <li class="camera-info-list">
              <span class="info-title">所属路线</span>
              <span class="info-value">{{cameraInfo.road}}</span>
            </li>
            <li class="camera-info-list">
              <span class="info-title">设备桩号</span>
              <span class="info-value">{{cameraInfo.pileNum}}</span>
            </li>
            <!-- <li class="camera-info-list">
              <span class="info-title">所属地区</span>
              <span class="info-value">{{cameraInfo.region}}</span>
            </li> -->
          </ul>
        </div>
      </template>
    </list-content>

  </div>
</template>

<script>
import ListContent from '../ListContent'
import ControlHand from '../ControlHand'
import { camNumsInfo } from "../cameramap";
import { getCameraPreset } from '@/api/system/user'

import EventBus from '@/utils/eventBus'
export default {
  components: { ListContent, ControlHand },
  data() {
    return {
      presetList: [],
      cameraInfo: {
      },
      cameraNum: '',
      cameraType: '',
      loading: false,
    };
  },
  created() {
    EventBus.$on('changeScreen', this.changeScreen)
  },

  mounted() {},

  methods: {
    changeScreen(params) {
      // console.log('视频控制：')
      // console.log(params)

      if (params.camID === this.cameraNum) return;
      
      this.cameraNum = params.camID || ''
      this.cameraType = params.ptz || '' // 是否有云台控制 0 可控制 1 不可控制

      if (this.cameraNum) {
        this.getCameraDetail()
        this.getPreset()
      } else {
        this.cameraInfo = {}
      }
    },

    /**
     * 获取相机预置位
     */
    getPreset() {
      this.presetList = []
      getCameraPreset({
        camId: this.cameraNum
      }).then(res => {
        this.presetList = res.data
      })
    },

    /** 摄像机详情 */
    getCameraDetail() {
      this.loading = true;
      camNumsInfo(this.cameraNum).then(res => {
        console.log('视频详情：')
        console.log(res)
        this.loading = false;
        this.cameraInfo = res.data;
      }).catch(err => {
        this.loading = false;
      })
    }
  },
};
</script>
<style lang="scss" scoped>
.right-content {
  // position: absolute;
  // right: 0;
  // top: 30px;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 16vw;
  height: 87vh;
  // float: right;
  // background-color: rgba(8, 28, 58, 0.6);
  overflow: hidden;
  .camera-info {
    margin-top: 10px;
    padding-left: 10px;
    overflow: scroll;
    .camera-info-list {
      display: flex;
      margin-bottom: 1.75vh;
      font-size: 13px;
      .info-title {
        width: 3.6vw;
        margin-right: 10px;
        flex: 0 0 auto;
      }
      .info-value {
        color: #59e5ff;
        // font-weight: bold;
        display: inline-block;
        // word-break: break-all;

        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
      }
    }
  }

  .camera-info::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  .control-box {
    height: 260px;
    width: 100%;
    position: relative;
    .control-hand {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 213px;
      height: 213px;
      .hand-top {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: 0;
        width: 114px;
        height: 40px;
        background: url(~@/assets/image/map-img/top.png) center no-repeat;
      }
      .hand-left {
        position: absolute;
        left: 0;
        transform: translateY(-50%);
        top: 50%;
        height: 114px;
        width: 40px;
        background: url(~@/assets/image/map-img/left.png) center no-repeat;
      }
      .hand-right {
        position: absolute;
        right: 0;
        transform: translateY(-50%);
        top: 50%;
        height: 114px;
        width: 40px;
        background: url(~@/assets/image/map-img/right.png) center no-repeat;
      }
      .hand-bottom {
        position: absolute;
        left: 50%;
        bottom: 0;
        transform: translateX(-50%);
        width: 114px;
        height: 40px;
        background: url(~@/assets/image/map-img/bottom.png) center no-repeat;
      }
      .hand-center {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 86px;
        height: 86px;
        background: url(~@/assets/image/map-img/circle-reset.png) center
          no-repeat;
      }
    }
  }
  .control-menu {
    display: flex;
    // justify-content: center;
    flex-wrap: wrap;
    .menu-item {
      // margin-left: 20px;
      margin-bottom: 10px;
      text-align: center;
      .icon-set {
        color: #1f77f3;
        font-size: 24px;
        vertical-align: middle;
      }
      .icon-des {
        margin-right: 18px;
        margin-left: 18px;
      }
    }
  }
}
</style>